package com.ruoyi.web.controller.fs;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.fs.domain.FsCapital;
import com.ruoyi.fs.service.IFsCapitalService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 资方信息Controller
 * 
 * @author hero
 * @date 2024-08-27
 */
@RestController
@RequestMapping("/fs/capital")
public class FsCapitalController extends BaseController
{
    @Autowired
    private IFsCapitalService fsCapitalService;

    /**
     * 查询资方信息列表
     */
    @PreAuthorize("@ss.hasPermi('fs:capital:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsCapital fsCapital)
    {
        startPage();
        List<FsCapital> list = fsCapitalService.selectFsCapitalList(fsCapital);
        return getDataTable(list);
    }

    /**
     * 导出资方信息列表
     */
    @PreAuthorize("@ss.hasPermi('fs:capital:export')")
    @Log(title = "资方信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FsCapital fsCapital)
    {
        List<FsCapital> list = fsCapitalService.selectFsCapitalList(fsCapital);
        ExcelUtil<FsCapital> util = new ExcelUtil<FsCapital>(FsCapital.class);
        util.exportExcel(response, list, "资方信息数据");
    }

    /**
     * 获取资方信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('fs:capital:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fsCapitalService.selectFsCapitalById(id));
    }

    /**
     * 新增资方信息
     */
    @PreAuthorize("@ss.hasPermi('fs:capital:add')")
    @Log(title = "资方信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsCapital fsCapital)
    {
        return toAjax(fsCapitalService.insertFsCapital(fsCapital));
    }

    /**
     * 修改资方信息
     */
    @PreAuthorize("@ss.hasPermi('fs:capital:edit')")
    @Log(title = "资方信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsCapital fsCapital)
    {
        return toAjax(fsCapitalService.updateFsCapital(fsCapital));
    }

    /**
     * 删除资方信息
     */
    @PreAuthorize("@ss.hasPermi('fs:capital:remove')")
    @Log(title = "资方信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsCapitalService.deleteFsCapitalByIds(ids));
    }
}
